<?php

/*
	[ English learning assistant system]
	NAME:admin_model
*/
if (!defined('IN_ELS'))
{
    die('Hacking attempt');
}

class homebase extends base {
	function homebase() {
		$this->base();
	}


	// 首页头部banner轮播图
	function  getbanner($num)
	{
		$sqlText = "select * from gnw_banner where 1=1 and is_ok=1 order by create_time desc limit $num";
		$retData = $this->db->fetch_all($sqlText);
		foreach($retData as $k=>$v)
		{
			$sql_user = "select fans_num from gnw_user where id=".$v['u_id'];//查询评论数，粉丝数 喜欢数
			$retData[$k]['fans_num'] = $this->db->result_first($sql_user);
		}
		return $retData;		
	}



	function gethuodongshopswitch(){
		$sqlText = "select * from setting where id = '1'";
		$retData = $this->db->fetch_first($sqlText);
		return $retData;
	}
	function getUserInfo($eid){
		$sqlText = "select *,FROM_UNIXTIME(create_time,'%Y-%m-%d ') create_time from editors where eid = $eid";
		$retData = $this->db->fetch_first($sqlText);
		return $retData;
	}
	function getPromotionList(){
		$sqlText = "select * from promotion where 1=1 order by create_time desc limit 0,7";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function getRotateList(){
		$sqlText = "select * from rotate where 1=1 order by create_time desc limit 0,6";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function gethomefoodList(){
		$sqlText = "select * from food where home_recommend = '1' order by home_recommend_time desc limit 0,5";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function gethomeshopList(){
		$sqlText = "select * from food_shop where home_recommend = '1' order by home_recommend_time desc limit 0,8";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function gethomeEntertList(){
		$sqlText = "select * from entertainment where recommend = '1' order by recommend_time desc limit 0,8";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function getCommentsCount($eid){
		$sqlText = "select count(*) from comments where eid = '$eid' ";
		$retData = $this->db->result_first($sqlText);
		return $retData;
	}
	
	function getUrlList(){
		$sqlText = "select * from url where 1=1 order by create_time desc ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function getPromotionClass($id){
		$sqlText = "select name from promotion_class where id1= $id";
		$retData = $this->db->fetch_first($sqlText);
		return $retData;
	}
	function getShijianClass(){
		$sqlText = "select * from shijian_class limit 0,10 ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function getAddrClass(){
		$sqlText = "select * from addr_class limit 0,12 ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function getEntertClass(){
		$sqlText = "select * from enter_class limit 0,10 ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function getGongyiClass(){
		$sqlText = "select * from gongyi_class ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function getTypeClass(){
		$sqlText = "select * from type_class ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	function upUser($data,$where){
		$retValue = $this->dbUpdate("editors",$data,$where);
		return $retValue;
	}
	//首页广告头部
	function getHomeAdBanner_01(){
		$sqlText = "select * from ad where type = '1' order by create_time limit 0,1 ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	//首页广告中部
	function getHomeAdBanner_02(){
		$sqlText = "select * from ad where type = '2' order by create_time limit 0,1 ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	//首页广告促销信息部分
	function getHomeAdBanner_03(){
		$sqlText = "select * from ad where type = '3' order by create_time limit 0,1 ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
	//首页广告促销信息部分
	function getHomeAdBanner_04(){
		$sqlText = "select * from ad where type = '5' order by create_time limit 0,1 ";
		$retData = $this->db->fetch_all($sqlText);
		return $retData;
	}
}
?>